home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / FORTRAN Goodies / String Utilities / string.f < prev    next >
Encoding:
Text File  |  1990-12-05  |  1.0 KB  |  53 lines  |  [TEXT/MPS ]

  1. c
  2. c    This example accepts either a string or a character argument
  3. c    and returns the argument as a string.
  4. c
  5. c    Example provided for owners of Language Systems FORTRAN
  6. c    © 1990 Language Systems Corp.
  7. c
  8. c    Written by Steven Hopkins
  9. c
  10.     string function String(Str_Char_Arg)
  11.     
  12.     implicit none
  13.  
  14. C        receive the argument by Descriptor
  15.  
  16.     structure /DescRec/
  17.         pointer /character*1/ DataPtr
  18.         integer*2 DataSize
  19.         integer*2 SymT
  20.     end structure
  21.     record /DescRec/ Str_Char_Arg
  22.     
  23.     integer*2 chard,strngd
  24.     parameter (chard=18,strngd=19)
  25.     pointer /character*1/ CharPtr
  26.     integer*4 size
  27.  
  28. C        point to the characters so we can look
  29. C        at them without changing the descriptor
  30.  
  31.     CharPtr = Str_Char_Arg.DataPtr
  32.  
  33. C        decide if the argument is a character
  34. C        or a string
  35.  
  36.     if (Str_Char_Arg.SymT == strngd) then
  37.         size = ichar(Str_Char_Arg.DataPtr^)
  38.         CharPtr = CharPtr + 1
  39.     else
  40.         size =Str_Char_Arg.DataSize
  41.     end if
  42.  
  43. C        make sure that argument will fit into a string
  44.  
  45.     size = MIN(255,size)
  46.  
  47. C        return characters as a string
  48. C        (turn range checking off)
  49. !!R-
  50.     String = CharPtr^(1:size)
  51.  
  52.     end
  53.